import express from 'express';
import bodyParser from 'body-parser';
import cookieParser from 'cookie-parser';
import cookieSession from 'cookie-session';
import uuid from  'uuid';
import consolidate from 'consolidate';
import multer from 'multer';
import logger from 'morgan';

let multerObj = multer({dest:"./public/upload"});

let app = express();
app.listen(8080);

//中间件
app.use(express.static("./public"));
app.use(multerObj.any());//容许所有文件上传
app.use(logger("dev"));
app.use(logger("combined",{stream:require("fs").createWriteStream("./logs/logs/log",{flags:"a"})}));

app.use(bodyParser.urlencoded({extended: true,limit: '500mb'}));
app.use(bodyParser.json());
app.use(bodyParser.text());

app.use(cookieParser("cs1803"));
app.use(cookieSession({
    genid:function () {
        return uuid.v1();
    },
    maxAge: 20*1000*60,
    secret:"cs1803"
}));

//模板引擎
app.set("view engine","html");
app.set("views","./views");
app.engine("html",consolidate.ejs);

//admin 路由

app.use("./admin",require("./route/admin/adminRoduer"));

//admin
